﻿using System;
using System.Web.UI.WebControls;
using Bingosoft.Modules.DataDictionary;
using Bingosoft.Web.Utils;


namespace HHMMS.UI.Modules.StorageManager
{
    public partial class StorageList3 : System.Web.UI.Page
    {
        private StorageService storageService = new StorageService();
        protected void Page_Load(object sender, EventArgs e)
        {
            ((TextBox)ControlHelper.FindControl(GridSearch, "txtOrgId")).Text = Bingosoft.Security.SecurityContext.User.Properties["OrgId"] + "";
        }

        protected void SearchGrid(object sender, EventArgs e)
        {
            this.GridSearch.Search();
        }

        protected void RefreshGrid(object sender, EventArgs e)
        {
            this.GridSearch.Refresh();
        }

        protected void DeleteDictionaryItem(object sender, EventArgs e)
        {
            var _sender = sender as ImageButton;
            String Id = _sender.Attributes["_KeyId"];

            this.storageService.DeleteDataItem(Id);

            RefreshGrid(sender, e);
        }

        protected void SmartGridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //ImageButton enableImgBtn = e.Row.FindControl("EnableImageButton") as ImageButton;
                //ImageButton disableImgBtn = e.Row.FindControl("DisableImageButton") as ImageButton;
                //string status = enableImgBtn.Attributes["_STATUS"];
                //if ("enabled".Equals(status))
                //{
                //    enableImgBtn.Visible = false;
                //    disableImgBtn.Visible = true;
                //}
                //else
                //{
                //    enableImgBtn.Visible = true;
                //    disableImgBtn.Visible = false;
                //}
            }
        }
        protected void LinkButtonExport_Click(object sender, EventArgs e)
        {
            this.SmartGridView1.SaveAsXls(string.Format("委外修的配件或材料入库{0:yyyyMM}.xls", DateTime.Now), true, this.SmartGridView1.Columns.Count - 1);
        }
    }
}